package fun.codedesign.yinxue.code.php;

import fun.codedesign.yinxue.code.engine.antlr.php.PhpLexer;
import fun.codedesign.yinxue.code.engine.antlr.php.PhpParser;
import fun.codedesign.yinxue.code.php2java.service.visitor.listener.Php2JavaListener;
import fun.codedesign.yinxue.util.ResourceUtil;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;

public class Php2Java {
    public static void main(String[] args) throws Exception {
        test1();
    }

    public static String phpExampleCode() {
        return ResourceUtil.getResourceAsText("manager.php");

    }

    static void test1() throws Exception {
        CharStream input = new ANTLRInputStream(ResourceUtil.getResourceAsInputStream("manager.php"));
        PhpLexer lexer = new PhpLexer(input);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        PhpParser parser = new PhpParser(tokens);
        ParseTree tree = parser.htmlDocument();
        ParseTreeWalker walker = new ParseTreeWalker();
        walker.walk(new Php2JavaListener(), tree);
    }

    public static String convertToJava(String text) {
        return null;
    }

    public static String readPhpAsAstCode(String text) {
        return null;
    }

}
